import java.util.Scanner;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86186
 * Date: 2023-10-17
 * Time: 10:27
 */
public class Test {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        String s = in.nextLine();
        String[] ret = new String[12];
        int i = 0, n = s.length(), begin = 0, cur = 0, count = 0;
        while (i < n) {
            if (s.charAt(i) == '"') {
                begin = ++i;
                while (i < n && s.charAt(i) != '"') {
                    i++;
                }
                ret[cur++] = s.substring(begin, i);
                count++;
                i += 2;
            }else {
                begin = i;
                while (i < n && s.charAt(i) != ' ') {
                    i++;
                }
                ret[cur++] = s.substring(begin, i);
                count++;
                i++;
            }
        }
        for (i = 0; i < count; i++) {
            System.out.println(ret[i]);
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int begin = in.nextInt(), end = in.nextInt();
            if (end < begin) {
                System.out.println(-1);
                break;
            }
            int i = begin, step = 0;
            while (i <= end) {
                int t = Divisor(i);
                i += t;
                step++;
            }

            System.out.println(step);
        }
    }

    private static int Divisor(int n) {
        if (n % 2 == 0) return n / 2;
        else return n % 3;
    }
}
